//*******************************//
// Strange, fruit-bearing plants //
//*******************************//

var/list/fruit_icon_states = list("badrecipe","kudzupod","reishi","lime","grapes","boiledrorocore","chocolateegg")
var/list/reagent_effects = list("anti_toxin","stoxin","space_drugs","mindbreaker","nutriment", "alkysine", "plasma", "morphine", "kelotane", "tricordrazine", "impedrezene","acid","methamphetamine","cryoxadone","imidazoline","hyronalin","synaptizine","dexalinp","cryptobiolin","virus_food","ryetalyn","uranium","blood")
var/list/reagent_effects2 = list("anti_toxin","stoxin","space_drugs","mindbreaker","nutriment", "alkysine", "plasma", "morphine", "kelotane", "tricordrazine", "impedrezene","acid","methamphetamine","cryoxadone","imidazoline","hyronalin","synaptizine","dexalinp","cryptobiolin","virus_food","ryetalyn","uranium","blood")
var/jungle_plants_init = 0

/proc/init_jungle_plants()
	jungle_plants_init = 1
	fruit_icon_states = shuffle(fruit_icon_states)
	reagent_effects = shuffle(reagent_effects)
	reagent_effects2 = shuffle(reagent_effects2)

/obj/item/weapon/reagent_containers/food/snacks/jungle_fruit
	name = "jungle fruit"
	desc = "It smells weird and looks off."
	icon = 'jungle.dmi'
	icon_state = "orange"

/obj/structure/jungle_plant
	icon = 'jungle.dmi'
	icon_state = "plant1"
	desc = "Looks like some of that fruit might be edible."
	var/fruits_left = 3
	var/fruit_type = -1
	var/icon/fruit_overlay
	var/plant_strength = 1
	var/fruit_r
	var/fruit_g
	var/fruit_b


/obj/structure/jungle_plant/New()
	if(!jungle_plants_init)
		init_jungle_plants()

	fruit_type = rand(1,7)
	icon_state = "plant[fruit_type]"
	fruits_left = rand(2,5)
	fruit_overlay = icon('jungle.dmi',"fruit[fruits_left]")
	fruit_r = 255 - fruit_type * 36
	fruit_g = rand(1,255)
	fruit_b = fruit_type * 36
	fruit_overlay.Blend(rgb(fruit_r, fruit_g, fruit_b), ICON_ADD)
	overlays += fruit_overlay
	plant_strength = rand(20,100)

/obj/structure/jungle_plant/attack_hand(var/mob/user as mob)
	if(fruits_left > 0)
		fruits_left--
		user << "\blue You pick a fruit off [src]."

		var/obj/item/weapon/reagent_containers/food/snacks/jungle_fruit/J = new (src.loc)
		J.icon_state = fruit_icon_states[fruit_type]
		J.reagents.add_reagent("nutriment", 3)
		J.reagents.add_reagent(reagent_effects[fruit_type], 1+round((plant_strength / 20), 1))
		J.reagents.add_reagent(reagent_effects2[fruit_type], 1+round((plant_strength / 20), 1))
		J.amount = 1+round(J.reagents.total_volume / 2, 1)
		J.attack_hand(user)

		overlays -= fruit_overlay
		fruit_overlay = icon('jungle.dmi',"fruit[fruits_left]")
		fruit_overlay.Blend(rgb(fruit_r, fruit_g, fruit_b), ICON_ADD)
		overlays += fruit_overlay
	else
		user << "\red There are no fruit left on [src]."